/*
 * @Description: 类似选择器的输入框
 * @Author: iamsmiling
 * @Date: 2021-06-06 11:05:03
 * @LastEditTime: 2021-06-08 06:37:51
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:flutter/material.dart';

import 'text_field_label_tip.dart';

class SelectorTextField extends StatefulWidget {
  final String label;
  final bool isRequired;
  final Function()? showDemo;
  final String hintText;

  final Future? Function()? onTap;

  final Color dividerColor;

  SelectorTextField(
      {Key? key,
      required this.label,
      this.isRequired = true,
      this.showDemo,
      this.hintText = "请选择",
      this.dividerColor = const Color(0xFFEEEEEE),
      this.onTap})
      : super(key: key);

  @override
  _SelectorTextFieldState createState() => _SelectorTextFieldState();
}

class _SelectorTextFieldState extends State<SelectorTextField> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          Container(
            margin: EdgeInsets.symmetric(vertical: R.dimen.dp10),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                TextFieldLableTip(
                  label: widget.label,
                  showDemo: widget.showDemo,
                  isRequired: widget.isRequired,
                ),
                GestureDetector(
                  onTap: widget.onTap,
                  child: Row(
                    children: [
                      Text(
                        widget.hintText,
                        style: TextStyle(
                            fontSize: R.dimen.sp13, color: R.color.ff999999),
                      ),
                      Visibility(
                        visible: widget.onTap != null,
                        child: Container(
                          margin: EdgeInsets.only(left: R.dimen.dp10),
                          child: Image.asset(
                            R.image.next,
                            color: R.color.ffcccccc,
                          ),
                        ),
                      )
                    ],
                  ),
                )
              ],
            ),
          ),
          Divider(
            color: widget.dividerColor,
          )
        ],
      ),
    );
  }
}
